"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MjWeaveItem = void 0;
class MjWeaveItem {
    constructor(weaveType = 0, operateChair = 0, provideChair = 0, provideCard = 0, cardList = []) {
        this.operateChair = 0; //操作用户
        this.isScoreGang = true;
        this.cardList = [];
        this.weaveType = weaveType;
        this.operateChair = operateChair;
        this.provideChair = provideChair;
        this.provideCard = provideCard;
        this.cardList = cardList;
    }
    static pushMjWeaveItem(mjWeaveItem, mjWeaveList) {
        let isFind = false;
        if (mjWeaveItem.weaveType == MjWeaveItem.Weave_Type.AnGang
            || mjWeaveItem.weaveType == MjWeaveItem.Weave_Type.Gang) {
            for (let i = 0; i < mjWeaveList.length; i++) {
                let tempMjWeave = mjWeaveList[i];
                if (tempMjWeave.weaveType == MjWeaveItem.Weave_Type.Peng) {
                    if (tempMjWeave.provideCard == mjWeaveItem.provideCard) {
                        isFind = true;
                        //新家的，补杠，补杠砸
                        if (mjWeaveItem.weaveType == MjWeaveItem.Weave_Type.AnGang) {
                            mjWeaveItem.weaveType = MjWeaveItem.Weave_Type.Gang;
                        }
                        mjWeaveList[i] = mjWeaveItem;
                        break;
                    }
                }
            }
        }
        if (!isFind) {
            mjWeaveList.push(mjWeaveItem);
        }
    }
    static deleteHandCardByWeaveItem(mjWeaveItem, handCardList) {
        let deleteCardList = mjWeaveItem.cardList.concat();
        if (mjWeaveItem.weaveType == MjWeaveItem.Weave_Type.Gang || mjWeaveItem.weaveType == MjWeaveItem.Weave_Type.AnGang) {
            deleteCardList.push(mjWeaveItem.cardList[0]);
        }
        else if (mjWeaveItem.weaveType == MjWeaveItem.Weave_Type.Peng) {
            // deleteCardList = deleteCardList.splice(0, 2)
        }
        for (let i = 0; i < deleteCardList.length; i++) {
            for (let j = handCardList.length - 1; j >= 0; j--) {
                if (handCardList[j] == deleteCardList[i]) {
                    handCardList.splice(j, 1);
                    break;
                }
            }
        }
    }
    clone() {
        let mjWeaveItem = new MjWeaveItem();
        mjWeaveItem.weaveType = this.weaveType;
        mjWeaveItem.operateChair = this.operateChair;
        mjWeaveItem.provideChair = this.provideChair;
        mjWeaveItem.provideCard = this.provideCard;
        mjWeaveItem.cardList = this.cardList.concat();
        return mjWeaveItem;
    }
}
exports.MjWeaveItem = MjWeaveItem;
MjWeaveItem.Weave_Type = {
    Null: 0,
    Peng: 1,
    Gang: 2,
    AnGang: 3, //暗杠
    // Bian: 4, //边
    // Za: 5, //砸
    // GangZa: 6, //杠砸
    // AnGangZa: 7, //暗杠砸
    // Zuan: 8, //钻
};
